<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<!-- 

利用快速排序对整数数组 [9, 7, 5, 11, 3] 进行升序排序。（可选）
-->
<script>
    var a = [9, 7, 5, 11, 3];
    function fn(a) {
        var a = [...a];
        if (a.length <= 1) {
            return a;
        }
        var left = []; var right = [];
        var p = a[Math.floor(a.length / 2)];
        for (var i = 0; i < a.length; i++) {
            if (a[i] < p) {
                left.push(a[i])
            }
            if (a[i] > p) {
                right.push(a[i])
            }
        }
        return fn(left).concat([p], fn(right));
    }
    console.log(fn(a));


</script>

</html>